package com.example.demo.service;

import com.example.demo.entity.MaterialEntity;
import com.example.demo.entity.MaterialSearchBean;
import com.example.demo.mapper.MaterialMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class MaterialService {
    @Autowired
    MaterialMapper materialMapper;
    public List<MaterialEntity> materialFindAll() {
        return materialMapper.materialFindAll();
    }
    public List<MaterialEntity> materialSearchTask(MaterialSearchBean materialSearchBean) {
        return materialMapper.materialSearch(materialSearchBean);
    }

    public int materialSearchCount(MaterialSearchBean materialSearchBean) {
        return materialMapper.materialSearchCount(materialSearchBean);
    }

    public boolean materialSaveTask(MaterialEntity materialEntity) {
        if (materialEntity.getId() > 0) {
            return materialMapper.materialUpdate(materialEntity);
        } else {
            return materialMapper.materialInsert(materialEntity);
        }
    }

    public boolean materialDelTask(int id) {
        return materialMapper.materialDelete(id);
    }
}
